﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.ComponentModel;

namespace Components
{
    [System.ComponentModel.DefaultBindingProperty("DateTimeValue")]
    public class SGVMaskedDateTime : SGVMaskedTextBox, INotifyPropertyChanged 
    {
        public event PropertyChangedEventHandler PropertyChanged;
        public SGVMaskedDateTime()
            : base()
        {
            DateTimeValue = DateTime.Now;
            _bindingPropertyName = "DateTime";
            this.TextChanged += new EventHandler(SGVDateTime_TextChanged);
        }

        void SGVDateTime_TextChanged(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(this.Text))
            {
                
            }
        }


        Nullable<DateTime> _dateTime;

        public Nullable<DateTime> DateTimeValue
        {
            get { return _dateTime; }
            set 
            {
                _dateTime = value;
                if (_dateTime == null)
                {
                    this.Text = String.Empty;
                }
                else
                {
                    this.Text = _dateTime.ToString();
                }
                if (PropertyChanged != null)
                    PropertyChanged(this, new PropertyChangedEventArgs("DateID"));
            }
        }


    }
}
